package com.smartcampus.demo.repository;

import com.smartcampus.demo.domain.Gas;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;

public interface GasDao extends JpaRepository<Gas, Long> {

    // 查询最新的 n 个数据
    @Query(value = "SELECT * FROM gas ORDER BY time DESC LIMIT ?1", nativeQuery = true)
    List<Gas> findTopNByOrderByCreatedAtDesc(int n);
}
